home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / src / test / testb.sml < prev    next >
Encoding:
Text File  |  1997-08-18  |  1.1 KB  |  35 lines  |  [TEXT/R*ch]

  1. (* Evaluation order *)
  2.  
  3. (let val nil = [1,2] and _ =
  4.      raise Io{function = "WRONG",  name = "WRONG", cause = Fail "WRONG"}
  5.  in "DEAD" end)
  6. handle Bind => "OK" | _ => "WRONG";
  7. ((fn 0 => "WRONG") 1)
  8. handle Match => "OK" | _ => "WRONG";
  9.  
  10. (map (raise Io{function = "OK", name = "OK", cause = Fail "OK"})
  11.  (raise Io{function = "WRONG", name = "WRONG", cause = Fail "WRONG"}))
  12. handle Io x => [x];
  13.  
  14. (raise Io{function = "OK", name = "OK", cause = Fail "OK"},
  15.  raise Io{function = "WRONG", name = "WRONG", cause = Fail "WRONG"})
  16. handle Io x => (x, x);
  17.  
  18. {bbb = raise Io{function = "OK", name = "OK", cause = Fail "OK"},
  19.  aaa = raise Io{function = "WRONG", name = "WRONG", cause = Fail "WRONG"}}
  20. handle Io x => {aaa=x, bbb=x};
  21.  
  22. fun pr s = (TextIO.output (TextIO.stdOut, s); s);
  23. fun x7 a b c d e f g = (a, b, c, d, e, f, g);
  24. x7 "1" (pr "2") "3" (pr "4") "5" (pr "6") "7";
  25.  
  26. datatype ('a, 'b) AB = NILab | CONSab of {a: 'a, b: 'b};
  27. CONSab {a=pr "a", b=pr "b"};
  28. CONSab {b=pr "b", a=pr "a"};
  29.  
  30. (* Top-level bindings *)
  31.  
  32. val f = fn x => x;
  33. val f = fn 0 => 1 | x => x * f(x-1);
  34. if f 4 = 12 then "OK" else "WRONG";
  35.